﻿using System;
using System.Collections;
using mojoPortal.Web.Framework;

namespace ud_Controls
{
    /// <summary>
    /// encapsulates the feature instance configuration loaded from module settings into a more friendly object
    /// </summary>
    public class ControlsModuleConfiguration
    {
        public ControlsModuleConfiguration()
        { }

        public ControlsModuleConfiguration(Hashtable settings)
        {
            LoadSettings(settings);

        }

        private void LoadSettings(Hashtable settings)
        {
            if (settings == null) { throw new ArgumentException("must pass in a hashtable of settings"); }

            if (settings.Contains("CustomCssClassSetting"))
            {
                customCssClass = settings["CustomCssClassSetting"].ToString();
            }
            showLoginLinkSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowLoginLinkSetting", showLoginLinkSetting);
            showLoginNoLinkSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowLoginNoLinkSetting", showLoginNoLinkSetting);
            showWelcomeMessageSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowWelcomeMessageSetting", showWelcomeMessageSetting);
            showLogoutLinkSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowLogoutLinkSetting", showLogoutLinkSetting);
            showRegisterLinkSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowRegisterLinkSetting", showRegisterLinkSetting);
            showProfileLinkSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowProfileLinkSetting", showProfileLinkSetting);
            showDateTimeControlSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowDateTimeControlSetting", showDateTimeControlSetting);
            showMemberListLinkSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowMemberListLinkSetting", showMemberListLinkSetting);
            showOnlineStatisticsSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowOnlineStatisticsSetting", showOnlineStatisticsSetting);
            showOnlineMemberListSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowOnlineMemberListSetting", showOnlineMemberListSetting);
            showMembershipStatisticsSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowMembershipStatisticsSetting", showMembershipStatisticsSetting);
            showCounterSetting = WebUtils.ParseBoolFromHashtable(settings, "ShowCounterSetting", showCounterSetting);
            if (settings.Contains("DateTimeFormatSetting"))
            {
                dateTimeFormatSetting = settings["DateTimeFormatSetting"].ToString();
            }

            if (settings.Contains("HeaderTextSetting"))
            {
                headerText = settings["HeaderTextSetting"].ToString();
            }

            if (settings.Contains("FooterTextSetting"))
            {
                footerText = settings["FooterTextSetting"].ToString();
            }

            numberDisplay = WebUtils.ParseInt32FromHashtable(settings, "NumberDisplaySetting", numberDisplay);

            useImage = WebUtils.ParseBoolFromHashtable(settings, "UseImageSetting", useImage);
        }

        private string customCssClass = string.Empty;
        public string CustomCssClass
        {
            get { return customCssClass; }
        }

        private bool showLoginLinkSetting;
        public bool ShowLoginLinkSetting
        {
            get { return showLoginLinkSetting; }
        }

        private bool showLoginNoLinkSetting;
        public bool ShowLoginNoLinkSetting
        {
            get { return showLoginNoLinkSetting; }
        }

        private bool showWelcomeMessageSetting;
        public bool ShowWelcomeMessageSetting
        {
            get { return showWelcomeMessageSetting; }
        }

        private bool showLogoutLinkSetting;
        public bool ShowLogoutLinkSetting
        {
            get { return showLogoutLinkSetting; }
        }

        private bool showRegisterLinkSetting;
        public bool ShowRegisterLinkSetting
        {
            get { return showRegisterLinkSetting; }
        }
        private bool showProfileLinkSetting;
        public bool ShowProfileLinkSetting
        {
            get { return showProfileLinkSetting; }
        }
        private bool showMemberListLinkSetting;
        public bool ShowMemberListLinkSetting
        {
            get { return showMemberListLinkSetting; }
        }
        private bool showDateTimeControlSetting;
        public bool ShowDateTimeControlSetting
        {
            get { return showDateTimeControlSetting; }
        }
        private string dateTimeFormatSetting = string.Empty;
        public string DateTimeFormatSetting
        { get { return dateTimeFormatSetting; } }

        private bool showOnlineStatisticsSetting;
        public bool ShowOnlineStatisticsSetting
        {
            get { return showOnlineStatisticsSetting; }
        }
        private bool showOnlineMemberListSetting;
        public bool ShowOnlineMemberListSetting
        {
            get { return showOnlineMemberListSetting; }
        }
        private bool showMembershipStatisticsSetting;
        public bool ShowMembershipStatisticsSetting
        {
            get { return showMembershipStatisticsSetting; }
        }

        private int numberDisplay = 9;

        public int NumberDisplay
        {
            get { return numberDisplay; }
        }

        private string headerText = string.Empty;
        public string HeaderText
        {
            get { return headerText; }
        }

        private string footerText = string.Empty;
        public string FooterText
        {
            get { return footerText; }
        }

        private bool useImage;
        public bool UseImage
        {
            get { return useImage; }
        }

        private bool showCounterSetting;
        public bool ShowCounterSetting
        {
            get { return showCounterSetting; }
        }
    }
}